import axios from 'axios';

export async function getAllAnnouncements() {
    let resp = await axios.get("/api/announcements");
    console.log("resp:",resp);
    return resp.data;
}


export async function deleteAnnouncements(_id) {
    let resp = await axios.delete("/api/announcements/" + _id);
    return resp.data;
}
// export async function deleteAnnouncements(_id) {
//     let resp = await axios.put("/api/announcements/" + _id);
//     return resp.data;
// }

export async function getGLY() {
    let resp = await axios.get("/api/users");
    console.log(resp);
    return resp.data;
}

export async function addGLY(form) {
    let {name,content} = form;
    let resp = await axios.post("/api/announcements", {
        name,
        content
    });
    console.log(name,content);
    return resp.data;
}

export async function gaiGLY(form1) {
    let {_id,name, content} =form1
    console.log(form1);
    let resp = await axios.put("/api/announcements/"+_id,{name,content});
    console.log("resp:",resp);
    return resp.data;
}